package com.dd;

import com.chantel.tool.db.PageData;
import com.chantel.tool.db.PageTool;

public class PageControl
{
	public static PageData GetShenHeTongGuoDataByUser(int pageSize, int currentPage, int userId)
	{
		PageTool pgt = PageTool.getInstance();
		
		String sql = "select* from CaiGouBiaoTable where BiaoZhuangTai=" + SysGlobals.SH_STATE_TJ + " and YuanGongId = " + userId +" order by  ChuangJianShiJian desc";
		PageData pageData = pgt.getPageData(sql, currentPage, pageSize);
			
		return pageData;
	}
	
	public static PageData GetShenHeJuJueDataByUser(int pageSize, int currentPage, int userId)
	{	
		PageTool pgt = PageTool.getInstance();
		
		String sql = "select* from CaiGouBiaoTable where BiaoZhuangTai=" + SysGlobals.SH_STATE_JJ +" and YuanGongId="+ userId +" order by  ChuangJianShiJian desc";
		PageData pageData = pgt.getPageData(sql, currentPage, pageSize);
		
		return pageData;
	}
	
	public static PageData GetShenHeDengDaiDataByUser(int pageSize, int currentPage, int userId)
	{	
		PageTool pgt = PageTool.getInstance();
		
		String sql = "select* from CaiGouBiaoTable where BiaoZhuangTai=" + SysGlobals.SH_STATE_DD + " and YuanGongId="+ userId +" order by  ChuangJianShiJian desc";
		PageData pageData = pgt.getPageData(sql, currentPage, pageSize);
		
		return pageData;
	}
	
	public static PageData GetShenHeTongGuoDataByXiangMu(int pageSize, int currentPage, int xiangMuId)
	{
		PageTool pgt = PageTool.getInstance();
		
		String sql = "select* from CaiGouBiaoTable where BiaoZhuangTai=" + SysGlobals.SH_STATE_TJ + " and XiangMuId = " + xiangMuId +" order by  ChuangJianShiJian desc";
		PageData pageData = pgt.getPageData(sql, currentPage, pageSize);
			
		return pageData;
	}
	
	public static PageData GetShenHeJuJueDataByXiangMu(int pageSize, int currentPage, int xiangMuId)
	{	
		PageTool pgt = PageTool.getInstance();
		
		String sql = "select* from CaiGouBiaoTable where BiaoZhuangTai=" + SysGlobals.SH_STATE_JJ +" and XiangMuId="+ xiangMuId +" order by  ChuangJianShiJian desc";
		PageData pageData = pgt.getPageData(sql, currentPage, pageSize);
		
		return pageData;
	}
	
	public static PageData GetShenHeDengDaiDataByXiangMu(int pageSize, int currentPage, int xiangMuId)
	{	
		PageTool pgt = PageTool.getInstance();
		
		String sql = "select* from CaiGouBiaoTable where BiaoZhuangTai=" + SysGlobals.SH_STATE_DD + " and XiangMuId="+ xiangMuId +" order by  ChuangJianShiJian desc";
		PageData pageData = pgt.getPageData(sql, currentPage, pageSize);
		
		return pageData;
	}
	
	
	public static PageData GetCaiGouBaoJiaDanByMingCheng(String mingCheng, int currentPage, int pageSize, int userId, int ziDuanMing)
	{
		String sql = "";
		if(ziDuanMing == 1)
		{
			sql = "select CaiGouBiaoId, DanJuBiaoHao, CaiGouBiaoTable.MingCheng as BiaoMingCheng,ChuangJianShiJian, XiangMuTable.MingCheng as XiangMuMingCheng, BiaoZhuangTai from CaiGouBiaoTable, XiangMuTable where YuanGongId = " + userId + " and CaiGouBiaoTable.XiangMuId = XiangMuTable.XiangMuId " + " and CaiGouBiaoTable.MingCheng like '%" + mingCheng +"%' order by ChuangJianShiJian";
			//sql = "select* from CaiGouBiaoTable where YuanGongId = "+ userId + " and MingCheng like '%" + mingCheng +"%' order by ChuangJianShiJian";
		}
		else if(ziDuanMing == 2)
		{
			sql = "select CaiGouBiaoId, DanJuBiaoHao, CaiGouBiaoTable.MingCheng as BiaoMingCheng,ChuangJianShiJian, XiangMuTable.MingCheng as XiangMuMingCheng, BiaoZhuangTai from CaiGouBiaoTable, XiangMuTable where YuanGongId = " + userId + " and CaiGouBiaoTable.XiangMuId = XiangMuTable.XiangMuId " + " and XiangMuTable.MingCheng like '%" + mingCheng +"%' order by ChuangJianShiJian";
		}
		else if(ziDuanMing == 3)
		{
			sql = "select CaiGouBiaoId, DanJuBiaoHao, CaiGouBiaoTable.MingCheng as BiaoMingCheng,ChuangJianShiJian, XiangMuTable.MingCheng as XiangMuMingCheng, BiaoZhuangTai from CaiGouBiaoTable, XiangMuTable where YuanGongId = " + userId + " and CaiGouBiaoTable.XiangMuId = XiangMuTable.XiangMuId " + " and DanJuBiaoHao like '%" + mingCheng +"%' order by ChuangJianShiJian";
		}
		PageTool pgt = PageTool.getInstance();
		
		PageData pageData = pgt.getPageData(sql, currentPage, pageSize);
		
		return pageData;	
	}
	
	
	public static PageData GetAllCaiGouBaoJiaDan(int currentPage, int pageSize, int userId)
	{
		String sql = "select CaiGouBiaoId, DanJuBiaoHao, CaiGouBiaoTable.MingCheng as BiaoMingCheng,ChuangJianShiJian, XiangMuTable.MingCheng as XiangMuMingCheng, BiaoZhuangTai from CaiGouBiaoTable, XiangMuTable where YuanGongId = " + userId + " and CaiGouBiaoTable.XiangMuId = XiangMuTable.XiangMuId  order by ChuangJianShiJian";
		PageTool pgt = PageTool.getInstance();
		
		PageData pageData = pgt.getPageData(sql, currentPage, pageSize);
		
		return pageData;	
	}
}